Repository navigation
Fix #15080 FP uninitMemberVarNoCtor for const and reference members - #8910
autoantwort wants to merge 4 commits into
Conversation
A class without constructor whose non-static const or reference member has no default member initializer is not default constructible (or, for a const class type with a default constructor, default constructs it), so the member can never be left uninitialized. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…or for all members Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Any further changes requested? |
|
@claude review |
|
The approach makes sense: a const member of trivial type, or a reference member, with no initializer deletes the implicit default constructor, so every instance has to be initialized another way. One issue (inline): static const and static reference members are in the usage list too. The new check doesn't exclude them, so a declaration like Minor: it would be good to add a test for a const pointer member ( 🤖 Generated with Claude Code |
|
please check the results here: |
Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Test results for commit d9ff8a4 (tools/test-my-pr.py, main compared to this PR): Test: http://ec2-16-170-140-253.eu-north-1.compute.amazonaws.com/pr-8910/ Posted automatically by the cppcheck PR test runner. +N: warnings only with this PR, -N: warnings only with main. The AI review is written by Claude and can be wrong. |
https://trac.cppcheck.net/ticket/15080
gives
Member variable 'S::it' has no initializer. [uninitMemberVarNoCtor], andstruct S { int a = 0; const int b; int& c; };warns forbandc.A non-static const or reference member without default member initializer can't stay uninitialized: for trivial types the implicit default constructor is deleted, so every instance must initialize it, and a const class type is default-constructed. These members are now skipped by the no-constructor check.
Since f90a76f (#15072) this also shows up for class templates whose member type is a
usingalias.This PR was created by Claude Code (an AI coding agent) on behalf of @autoantwort.
🤖 Generated with Claude Code